package com.cloudkinto.controller.board;


import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.service.board.ChBoardService;
import com.cloudkinto.service.headercontainer.HeaderContainerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.cloudkinto.base.BaseController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhangyy
 * @since 2020-10-27
 */
@RestController
@Api(tags = "中国仓看板模块")
@RequestMapping("api/admin/chBoard")
public class ChBoardController extends BaseController {

    @Autowired
    private ChBoardService chBoardService;
    @Autowired
    private HeaderContainerService headerContainerService;

    @GetMapping("/init")
    @ApiOperation(value = "查询初始化", notes = "新增初始化")
    public SingleResult getInfo() {
        return chBoardService.getInfo();
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询", notes = "查询（分页）")
    @ApiImplicitParams({@ApiImplicitParam(value = "当前页" ,name = "current",paramType = "query",dataType = "String"),
            @ApiImplicitParam(value = "页面大小" ,name = "pageSize",paramType = "query",dataType = "String"),
            @ApiImplicitParam(value = "仓库id" ,name = "storageId",paramType = "query",dataType = "String"),
            @ApiImplicitParam(value = "状态" ,name = "status",paramType = "query",dataType = "String"),
            @ApiImplicitParam(value = "开始时间" ,name = "startDate",paramType = "query",dataType = "String"),
            @ApiImplicitParam(value = "结束时间" ,name = "endDate",paramType = "query",dataType = "String")})
    public SingleResult list(HttpServletRequest request) {

        Map<String, String> map = new HashMap<>();
        String storageId = request.getParameter("storageId");
        String status = request.getParameter("status");
        String startDate = request.getParameter("startDate");
        String endDate = request.getParameter("endDate");
        String current = request.getParameter("current");
        String size = request.getParameter("pageSize");
        map.put("storageId", storageId);
        map.put("status", status);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        map.put("current", current);
        map.put("pageSize", size);
        return SingleResult.success(headerContainerService.getList(map));
    }

    @GetMapping("/getInfoByDate")
    @ApiOperation(value = "查看某一天的订单信息", notes = "新增初始化")
    public SingleResult getInfoByDate(@RequestParam String startDate, @RequestParam String endDate,@RequestParam String storageId) {
        return chBoardService.getInfoByDate(startDate,endDate,storageId);
    }

    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "新增初始化")
    public SingleResult detail(@RequestParam Long id) {
        return chBoardService.detail(id);
    }
}

